package autogen;

<%@page import="static hh.EmptyUtil.*,hh.*" %>
<%String doName = toCamelCaseRemovePreAndSuffix(table.tableName, "st", "1");%>

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import autogen.dao.<%=doName%>Dao;
import autogen.domain.<%=doName%>DO;
import autogen.domain.<%=doName%>PageDTO;
import autogen.mapper.<%=doName%>Mapper;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * <%=table.tableName%>表 daoImpl
 * @author mybatis-orm auto generator
 */
@Repository
public class <%=doName%>DaoImpl extends ServiceImpl<<%=doName%>Mapper, <%=doName%>DO> implements <%=doName%>Dao{

    @Override
    public boolean create(<%=doName%>DO entity) {
        if (entity == null) return false;
        return save(entity);
    }
    
    @Override
    public boolean createBatch(List<<%=doName%>DO> entities) {
        if (entities == null || entities.isEmpty()) return false;
        return saveBatch(entities);
    }
    
    @Override
    public boolean deleteById(Long id) {
        if (id == null) return false;
        return removeById(id);
    }
    
    @Override
    public boolean deleteBatchByIds(List<Long> ids) {
        if (ids == null || ids.isEmpty()) return false;
        return removeByIds(ids);
    }
    
    @Override
    public boolean delete(Wrapper<<%=doName%>DO> wrapper) {
        return remove(wrapper);
    }
    
    @Override
    public <%=doName%>DO findById(Long id) {
        if (id == null) return null;
        return getById(id);
    }
    
    @Override
    public List<<%=doName%>DO> listPage(<%=doName%>PageDTO query) {
        if (query == null) return new ArrayList<>(0);
        return baseMapper.listPage(query);
    }


    @Override
    public List<<%=doName%>DO> list(Wrapper<<%=doName%>DO> wrapper) {
        return super.list(wrapper);
    }

    @Override
    public <%=doName%>DO findOne(Wrapper<<%=doName%>DO> wrapper) {
        return super.getOne(wrapper);
    }
    
    @Override
    public boolean updateBatchByIds(List<<%=doName%>DO> entities) {
        return updateBatchById(entities);
    }

    @Override
    public boolean updateById(<%=doName%>DO entity) {
        return updateById(entity);
    }
}
